package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.entity.CertificationInformation;
import com.itheima.mapper.CertificationInformationMapper;
import com.itheima.result.PageResult;
import com.itheima.service.ICertificationInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CertificationInformationServiceImpl implements ICertificationInformationService {
    @Autowired
    private CertificationInformationMapper informationMapper;

    /**
     * 查询用户认证数据列表
     * @param certificationInformation
     * @return
     */
    @Override
    public PageResult selectCertificationInformationList(CertificationInformation information) {
        PageHelper.startPage(information.getPageNum(), information.getPageSize());
        Page<CertificationInformation> page = informationMapper.selectCertificationInformationList(information);
        return new PageResult(page.getTotal(), page.getResult());
    }
    /**
     * 新增用户认证数据
     * @param
     * @return
     */
    @Override
    public int insertCertificationInformation(List<CertificationInformation> informations) {
        for (CertificationInformation information : informations) {
            information.setCreateDate(LocalDateTime.now());
            information.setUpdateDate(LocalDateTime.now());
            informationMapper.insertCertificationInformation(information);
        }
        return 1;
    }
    /**
     * 修改用户认证数据
     * @param information
     * @return
     */
    @Override
    public int updateCertificationInformation(CertificationInformation information) {
        information.setUpdateDate(LocalDateTime.now());
        return informationMapper.updateCertificationInformation(information);
    }

    /**
     * 删除用户认证数据
     * @param ids
     * @return
     */
    @Override
    public int deleteCertificationInformationByIds(Long[] ids) {
        return informationMapper.deleteCertificationInformationByIds(ids);
    }
}
